@include('header')
@include('template.banner')

<!-- 添加 element-ui 样式 -->
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
<!-- 添加 jquery-toast-plugin 样式 -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-toast-plugin/1.3.2/jquery.toast.min.css">
<!-- 引入jquery和jquery-toast-plugin -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-toast-plugin/1.3.2/jquery.toast.min.js"></script>

<style>
.el-checkbox {
    margin-right: 15px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    position: relative;
}
.el-checkbox__label {
    cursor: pointer;
    padding-left: 8px;
}
.el-checkbox__input {
    white-space: nowrap;
    cursor: pointer;
    outline: none;
    display: inline-flex;
    position: relative;
}
.el-checkbox__inner {
    display: inline-block;
    position: relative;
    border: 1px solid #DCDFE6;
    border-radius: 2px;
    box-sizing: border-box;
    width: 14px;
    height: 14px;
    background-color: #FFF;
    z-index: 1;
    transition: border-color .25s cubic-bezier(.71,-.46,.29,1.46),background-color .25s cubic-bezier(.71,-.46,.29,1.46);
}
.el-checkbox__input.is-checked .el-checkbox__inner {
    background-color: #409EFF;
    border-color: #409EFF;
}
.el-checkbox__input.is-checked .el-checkbox__inner:after {
    transform: rotate(45deg) scaleY(1);
}
.el-checkbox__inner:after {
    box-sizing: content-box;
    content: "";
    border: 1px solid #FFF;
    border-left: 0;
    border-top: 0;
    height: 7px;
    left: 4px;
    position: absolute;
    top: 1px;
    transform: rotate(45deg) scaleY(0);
    width: 3px;
    transition: transform .15s ease-in .05s;
    transform-origin: center;
}
.el-checkbox__original {
    opacity: 0;
    outline: none;
    position: absolute;
    margin: 0;
    width: 0;
    height: 0;
    z-index: -1;
}
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}
.toast {
    padding: 15px 20px;
    margin-bottom: 10px;
    border-radius: 4px;
    color: white;
    opacity: 0;
    transition: opacity 0.3s;
    box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);
}
.toast-error {
    background-color: #f56c6c;
}
.toast-success {
    background-color: #67c23a;
}
.toast.show {
    opacity: 1;
}
</style>

<div class="container contactus">


    <div class="sub-nav-box">
        <div class="tit">
            联系我们 / <span>Contact us</span>
        </div>
        <div class="en-tit">如果您有法律上的事情咨询，请联系我们，我们将给您较好的帮助</div>
        <div class="sub-nav visible-md hidden-sm hidden-xs" id="subNav">

        </div>
    </div>
    <script type="text/javascript">
        var $subNav = $("#subNav");
        $subNav.children("ul").find("li").InitNav(168);


        $subNav = $("#subNav");
        $subNav.find("li[data-id='168']").addClass("active");
        var $subLis = $subNav.find("li");
        var $subLi = $subNav.find("li[data-id='168']");
        $subLis.each(function () {
            var $this = $(this);
            $this.children("a").on("mouseenter", function () {
                $subLis.removeClass("active");
                $this.addClass("active");
            })
        });
        $subNav.on("mouseleave", function () {
            $subLis.removeClass("active");
            $subLi.addClass("active");
        })
    </script>


    <div class="text-center padding-bottom-40 headline">
        <p class="callMe-text">
            客户利益至上是我们一贯恪守的执业准则，律师以优良的职业素养、勤勉职责的敬业精神、诚实信用的处事原则，为客户提供优质高效的专业法律服务，较大限度地维护和实现客户利益。为了更好地了解客户需求，不断改善服务质量和效率。
        </p>
    </div>

    <!--联系方式-->
    <div class="address row text-center">
        <div class="col-md-4 col-sm-4 padding-top-20">
            <img src="{{asset('images/address1.png')}}" />
            <p>{{$address}}</p>
        </div>
        <div class="col-md-4 col-sm-4 padding-top-20">
            <img src="{{asset('images/address2.png')}}" />
            <p>{{$phone}}</p>
        </div>
        <div class="col-md-4 col-sm-4 padding-top-20">
            <img src="{{asset('images/address3.png')}}" />
            <p>{{$email}}</p>
        </div>
    </div>

    <div class="position-relative">
        <!--地图-->
        <div class="info-content">
            <script src="http://api.map.baidu.com/api?v=1.4"></script>
            <style>
                #mapbox{width: 100%;height: 400px;overflow: hidden;border: 1px solid #ccc;}
                @media (min-width:1000px){#mapbox{height: 350px;}}
                @media (max-width:1000px){#mapbox{height: 300px;margin-top: 20px;}}
            </style>
            <div id="mapbox"></div>
            <script>
                var map = new BMap.Map("mapbox");            // 创建Map实例，必须和地图容器id一致
                var point = new BMap.Point(113.876017, 23.080854); // 创建点坐标
                map.centerAndZoom(point, 20);                 // 初始化地图,设置中心点坐标和地图级别，最大19级
                map.enableScrollWheelZoom();                 //启用滚轮放大缩小
                map.addControl(new BMap.NavigationControl());
                map.addControl(new BMap.ScaleControl());
                map.addControl(new BMap.OverviewMapControl());
                var marker = new BMap.Marker(point);
                map.addOverlay(marker);
                var infoWinOpts = {}
                var sitetxt = "<div style='text-align:left;color:#333;line-height:25px;margin:0 auto;width:280px;'><li>地址：{{$address}}</li></div>";
                var infoWin = new BMap.InfoWindow(sitetxt, infoWinOpts);
                marker.openInfoWindow(infoWin);
                marker.addEventListener("click", function () { this.openInfoWindow(infoWin); });//注册点击事件
            </script>
        </div>
    </div>


    <!--资讯-->
    <div class="sub-nav-box addsubnav">
        <div class="tit">
            留言
        </div>
        <div class="en-tit">留下您的联系方式我们会在第一时间联系您</div>
    </div>

    <!--需要先引用以下js文件，并保证每个页面只引用一次,多余脚本代码请自行优化或删除-->
    <div id="FeedbackForm">
        <form action="/message" method="post" class="el-form el-form--label-left" onsubmit="return validateForm()">
            @csrf
            <input type="hidden" name="table" value="Message">
            
            <div class="el-form-item">
                <label class="el-form-item__label">姓名</label>
                <div class="el-form-item__content">
                    <div class="el-input">
                        <input type="text" name="name" maxlength="150" class="el-input__inner" required>
                    </div>
                    <span class="help-block"></span>
                </div>
            </div>

            <div class="el-form-item">
                <label class="el-form-item__label">手机</label>
                <div class="el-form-item__content">
                    <div class="el-input">
                        <input type="text" name="mobile" maxlength="11" class="el-input__inner" required pattern="^1[3-9]\d{9}$" title="请输入正确的11位手机号">
                    </div>
                    <span class="help-block"></span>
                </div>
            </div>

            <div class="el-form-item">
                <label class="el-form-item__label">咨询</label>
                <div class="el-form-item__content">
                    <div class="el-checkbox-group" id="consultCheckboxes" style="display: flex; flex-wrap: nowrap; align-items: center; white-space: nowrap; overflow-x: auto; padding: 10px 0;">
                        <label class="el-checkbox-wrapper" style="cursor: pointer; margin-right: 15px; display: inline-flex; align-items: center; white-space: nowrap;">
                            <input type="checkbox" name="target[]" value="婚姻家庭" style="margin-right: 5px;">
                            <span style="color: #333; font-size: 14px;">婚姻家庭</span>
                        </label>
                        <label class="el-checkbox-wrapper" style="cursor: pointer; margin-right: 15px; display: inline-flex; align-items: center; white-space: nowrap;">
                            <input type="checkbox" name="target[]" value="金融资本" style="margin-right: 5px;">
                            <span style="color: #333; font-size: 14px;">金融资本</span>
                        </label>
                        <label class="el-checkbox-wrapper" style="cursor: pointer; margin-right: 15px; display: inline-flex; align-items: center; white-space: nowrap;">
                            <input type="checkbox" name="target[]" value="陪同谈判" style="margin-right: 5px;">
                            <span style="color: #333; font-size: 14px;">陪同谈判</span>
                        </label>
                        <label class="el-checkbox-wrapper" style="cursor: pointer; margin-right: 15px; display: inline-flex; align-items: center; white-space: nowrap;">
                            <input type="checkbox" name="target[]" value="公司企业" style="margin-right: 5px;">
                            <span style="color: #333; font-size: 14px;">公司企业</span>
                        </label>
                        <label class="el-checkbox-wrapper" style="cursor: pointer; margin-right: 15px; display: inline-flex; align-items: center; white-space: nowrap;">
                            <input type="checkbox" name="target[]" value="知识产权" style="margin-right: 5px;">
                            <span style="color: #333; font-size: 14px;">知识产权</span>
                        </label>
                        <label class="el-checkbox-wrapper" style="cursor: pointer; margin-right: 15px; display: inline-flex; align-items: center; white-space: nowrap;">
                            <input type="checkbox" name="target[]" value="诉讼&裁判" style="margin-right: 5px;">
                            <span style="color: #333; font-size: 14px;">诉讼&裁判</span>
                        </label>
                        <label class="el-checkbox-wrapper" style="cursor: pointer; margin-right: 0; display: inline-flex; align-items: center; white-space: nowrap;">
                            <input type="checkbox" name="target[]" value="其他" style="margin-right: 5px;">
                            <span style="color: #333; font-size: 14px;">其他</span>
                        </label>
                    </div>
                    <span class="help-block" id="consultError" style="color: #F56C6C;"></span>
                </div>
            </div>

            <div class="el-form-item">
                <label class="el-form-item__label">内容</label>
                <div class="el-form-item__content">
                    <div class="el-textarea">
                        <textarea name="content" class="el-textarea__inner" rows="4" required maxlength="200" onkeyup="this.nextElementSibling.innerHTML = this.value.length + '/200'"></textarea>
                        <div style="text-align: right; color: #909399; font-size: 12px; margin-top: 5px;">0/200</div>
                    </div>
                    <span class="help-block"></span>
                </div>
            </div>

            <div class="el-form-item">
                <label class="el-form-item__label">验证码</label>
                <div class="el-form-item__content">
                    <div style="display: flex; align-items: center;">
                        <div class="el-input" style="width: 150px; margin-right: 10px;">
                            <input type="text" name="captcha" class="el-input__inner" required>
                        </div>
                        <div>
                            {!! captcha_img() !!}
                            <button type="button" class="el-button el-button--text" style="padding: 0; margin-left: 5px;" onclick="this.previousElementSibling.src='{{ captcha_src() }}'+Math.random();">
                                <span>刷新</span>
                            </button>
                        </div>
                    </div>
                    <span class="help-block"></span>
                </div>
            </div>

            <div class="el-form-item">
                <div class="el-form-item__content">
                    <button type="submit" class="el-button el-button--primary el-button--small">
                        <span>提交</span>
                    </button>
                </div>
            </div>
        </form>
    </div>

    <!-- 使用jquery-toast-plugin替代原来的Toast容器 -->

    @if(session('error'))
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            $.toast({
                heading: '错误提示',
                text: "{{ session('error') }}",
                showHideTransition: 'fade',
                icon: 'error',
                position: 'top-right',
                hideAfter: false,
                stack: 5,
                allowToastClose: true
            });
        });
    </script>
    @endif

    @if(session('success'))
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            $.toast({
                heading: '操作成功',
                text: "{{ session('success') }}",
                showHideTransition: 'slide',
                icon: 'success',
                position: 'top-right',
                hideAfter: 3000,
                stack: 5
            });
        });
    </script>
    @endif

    <script>
    function validateForm() {
        // 检查是否至少勾选一个咨询选项
        var checkboxes = document.querySelectorAll('input[name="target[]"]');
        var isChecked = false;
        
        for (var i = 0; i < checkboxes.length; i++) {
            if (checkboxes[i].checked) {
                isChecked = true;
                break;
            }
        }
        
        if (!isChecked) {
            $.toast({
                heading: '错误提示',
                text: '请至少选择一项咨询',
                showHideTransition: 'fade',
                icon: 'error',
                position: 'top-right',
                hideAfter: false,
                stack: 5,
                allowToastClose: true
            });
            return false;
        }
        return true;
    }
    </script>

</div>
@include('bottom')
